import cn.ssm.petadopt.entity.User;
import cn.ssm.petadopt.mapper.AdminsMapper;
import cn.ssm.petadopt.mapper.UserMapper;
import cn.ssm.petadopt.service.impl.UserServiceImpl;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @Autheor: Sun俊仪
 * @Date: 2022 2022/12/17 13:49
 * @Name: PetSystem
 */
public class App {

    @Test
    public void test01(){
        try {
            InputStream resourceAsStream = Resources.getResourceAsStream("config/mybatis-config.xml");
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
            SqlSession sqlSession = sqlSessionFactory.openSession();
            AdminsMapper mapper = sqlSession.getMapper(AdminsMapper.class);
            System.out.println("mapper = " + mapper);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test02(){
        ApplicationContext app = new ClassPathXmlApplicationContext("config/spring-config.xml");
        UserServiceImpl userServiceImpl = app.getBean("userServiceImpl", UserServiceImpl.class);

    }
}
